package com.lecture.java8.excel.dyr.a;

import com.alibaba.excel.EasyExcel;
import com.lecture.java8.excel.DemoDataListener;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Test0423 {
    public static void main(String[] args) {
        String dir = "D:\\study\\tmp\\0423\\";


        /*String result1 = dir + "1总资产固定资产_Combas.xlsx";
        DemoDataListener<Result0423_1> dataResultListener = new DemoDataListener<>();
        EasyExcel.read(result1, Result0423_1.class,dataResultListener).sheet().doRead();
        //全要素生产率
        List<Result0423_1> resultList = dataResultListener.getDataList();
        Map<String, Result0423_1> map1 = new HashMap<>();
        for (Result0423_1 result : resultList) {
            map1.put(result.getA() + "-" + result.getC().substring(0,4),result);
        }*/

        /*String result2 = dir + "2ROE.xlsx";
        DemoDataListener<Result0423_2> dataResultListener2 = new DemoDataListener<>();
        EasyExcel.read(result2, Result0423_2.class,dataResultListener2).sheet().doRead();
        //全要素生产率
        List<Result0423_2> resultList2 = dataResultListener2.getDataList();
        Map<String, Result0423_2> map2 = new HashMap<>();
        for (Result0423_2 result : resultList2) {
            map2.put(result.getA() + "-" + result.getC().substring(0,4),result);
        }*/

        /*String result3 = dir + "3资产负债率.xlsx";
        DemoDataListener<Result0423_3> dataResultListener3 = new DemoDataListener<>();
        EasyExcel.read(result3, Result0423_3.class,dataResultListener3).sheet().doRead();
        //全要素生产率
        List<Result0423_3> resultList3 = dataResultListener3.getDataList();
        Map<String, Result0423_3> map3 = new HashMap<>();
        for (Result0423_3 result : resultList3) {
            map3.put(result.getA() + "-" + result.getC().substring(0,4),result);
        }
*/
        /*String result4 = dir + "4营业收入增长率.xlsx";
        DemoDataListener<Result0423_4> dataResultListener4 = new DemoDataListener<>();
        EasyExcel.read(result4, Result0423_4.class,dataResultListener4).sheet().doRead();
        //全要素生产率
        List<Result0423_4> resultList4 = dataResultListener4.getDataList();
        Map<String, Result0423_4> map4 = new HashMap<>();
        for (Result0423_4 result : resultList4) {
            map4.put(result.getA() + "-" + result.getC().substring(0,4),result);
        }*/

        String result5 = dir + "5营业收入.xlsx";
        DemoDataListener<Result0423_5> dataResultListener5 = new DemoDataListener<>();
        EasyExcel.read(result5, Result0423_5.class,dataResultListener5).sheet().doRead();
        //全要素生产率
        List<Result0423_5> resultList5 = dataResultListener5.getDataList();
        Map<String, Result0423_5> map5 = new HashMap<>();
        for (Result0423_5 result : resultList5) {
            map5.put(result.getA() + "-" + result.getC().substring(0,4),result);
        }


        String result6 = dir + "6股东.xlsx";
        DemoDataListener<Result0423_6> dataResultListener6 = new DemoDataListener<>();
        EasyExcel.read(result6, Result0423_6.class,dataResultListener6).sheet().doRead();
        //全要素生产率
        List<Result0423_6> resultList6 = dataResultListener6.getDataList();
        Map<String, Result0423_6> map6 = new HashMap<>();
        for (Result0423_6 result : resultList6) {
            map6.put(result.getA() + "-" + result.getC().substring(0,4),result);
        }


        String result7 = dir + "7资本密集度.xlsx";
        DemoDataListener<Result0423_7> dataResultListener7 = new DemoDataListener<>();
        EasyExcel.read(result7, Result0423_7.class,dataResultListener7).sheet().doRead();
        //全要素生产率
        List<Result0423_7> resultList7 = dataResultListener7.getDataList();
        Map<String, Result0423_7> map7 = new HashMap<>();
        for (Result0423_7 result : resultList7) {
            map7.put(result.getA() + "-" + result.getC().substring(0,4),result);
        }


        String result8 = dir + "8每股收益.xlsx";
        DemoDataListener<Result0423_8> dataResultListener8 = new DemoDataListener<>();
        EasyExcel.read(result8, Result0423_8.class,dataResultListener8).sheet().doRead();
        //全要素生产率
        List<Result0423_8> resultList8 = dataResultListener8.getDataList();
        Map<String, Result0423_8> map8 = new HashMap<>();
        for (Result0423_8 result : resultList8) {
            map8.put(result.getA() + "-" + result.getC().substring(0,4),result);
        }


        String result9 = dir + "9托宾Q.xlsx";
        DemoDataListener<Result0423_9> dataResultListener9 = new DemoDataListener<>();
        EasyExcel.read(result9, Result0423_9.class,dataResultListener9).sheet().doRead();
        //全要素生产率
        List<Result0423_9> resultList9 = dataResultListener9.getDataList();
        Map<String, Result0423_9> map9 = new HashMap<>();
        for (Result0423_9 result : resultList9) {
            map9.put(result.getA() + "-" + result.getC().substring(0,4),result);
        }


        String dataResultFileName = dir + "显著性0.004的.xlsx";
        DemoDataListener<Model0423> dataListener = new DemoDataListener<>();
        EasyExcel.read(dataResultFileName, Model0423.class,dataListener).sheet().doRead();
        List<Model0423> dataList = dataListener.getDataList();

        for (Model0423 model : dataList) {
            String key = model.getA() + "-" + model.getB();
            Result0423_5 r5 = map5.get(key);
            if (r5 != null) {
                model.setAa(r5.getD());
            }

            Result0423_6 r6 = map6.get(key);
            if (r6 != null) {
                model.setAb(r6.getD());
                model.setAc(r6.getE());
            }


            Result0423_7 r7 = map7.get(key);
            if (r7 != null) {
                model.setAd(r7.getD());
                model.setAe(r7.getE());
            }


            Result0423_8 r8 = map8.get(key);
            if (r8 != null) {
                model.setAf(r8.getD());

            }

            Result0423_9 r9 = map9.get(key);
            if (r9 != null) {
                model.setAg(r9.getD());
                model.setAh(r9.getE());
            }


        }

        EasyExcel.write(dir + "result3.xlsx", Model0423.class)
                .sheet("a").doWrite(dataList);
    }
}
